# !/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName : bubble_sort.py
# @Time     : 2024/1/30 1:19
# @Author   : Robot-Zsj
"""
description: 
"""
import pdb
from copy import deepcopy

Array = [50, 36, 66, 76, 95, 12, 25, 36, 24, 8]


def bubble_sort1(array):
    for i in range(0, len(array) - 1):
        for j in range(i + 1, len(array)):
            if array[i] > array[j]:
                array[i], array[j] = array[j], array[i]
    return array


print(bubble_sort1(Array))
Array = [1, 2, 3, 4]


def bubble_sort2(array):
    for i in range(0, len(array) - 1):
        flag = True
        for j in range(i + 1, len(array)):
            if array[i] > array[j]:
                array[i], array[j] = array[j], array[i]
                flag = False
        if flag:
            break
    return array


print(bubble_sort2(Array))
